home *** CD-ROM | disk | FTP | other *** search
- /*
- ==============================================================================
-
- Martian Soldiers
-
- ==============================================================================
- */
-
- #include "g_local.h"
- #include "m_player.h"
-
-
- static int sound_pain;
- static int sound_die;
- static int sound_idle;
- static int sound_punch;
- static int sound_sight;
- static int sound_search;
- static int sound_shoot;
- static int sound_glass;
-
-
- void martian_search (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0);
- }
-
- mframe_t martian_frames_stand [] =
- {
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
-
- };
- mmove_t martian_move_stand = {FRAME_stand01, FRAME_stand40, martian_frames_stand, NULL};
-
- void martian_stand (edict_t *self)
- {
- self->monsterinfo.currentmove = &martian_move_stand;
- }
-
- mframe_t martian_frames_run1 [] =
- {
- ai_run, 25, NULL,
- ai_run, 10, NULL,
- ai_run, 5, NULL,
- ai_run, 24, NULL,
- ai_run, 11, NULL,
- ai_run, 5, NULL
- };
- mmove_t martian_move_run1 = {FRAME_run1, FRAME_run6, martian_frames_run1, NULL};
-
- void martian_run (edict_t *self)
- {
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- self->monsterinfo.currentmove = &martian_move_stand;
- else
- self->monsterinfo.currentmove = &martian_move_run1;
- }
- mframe_t martian_frames_wave [] =
- {
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
- };
-
- mmove_t martian_move_wave = {FRAME_wave01, FRAME_wave11, martian_frames_wave, martian_run};
-
- mframe_t martian_frames_point [] =
- {
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
- };
-
- mmove_t martian_move_point = {FRAME_point01, FRAME_point12, martian_frames_point, martian_run};
-
- mframe_t martian_frames_flip [] =
- {
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
- };
-
- mmove_t martian_move_flip = {FRAME_flip01, FRAME_flip12, martian_frames_flip, martian_run};
-
- mframe_t martian_frames_taunt [] =
- {
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
- };
-
- mmove_t martian_move_taunt = {FRAME_taunt01, FRAME_taunt17, martian_frames_taunt, martian_run};
-
- void martian_run_after_shoot (edict_t *self)
- {
- if (random() < 0.8)
- self->monsterinfo.currentmove = &martian_move_run1;
- else
- {
- if(random() < 0.5)
- self->monsterinfo.currentmove = &martian_move_flip;
- else
- self->monsterinfo.currentmove = &martian_move_taunt;
- }
- }
-
- void MartianShot (edict_t *self)
- {
- vec3_t forward, right;
- vec3_t start;
- vec3_t end;
- vec3_t dir;
- vec3_t from;
- int damage = 15;
- int flash_number = MZ2_MAKRON_BFG;
- trace_t tr;
-
- if (self->spawnflags & 1)
- damage = 20;
-
- AngleVectors (self->s.angles, forward, right, NULL);
- G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
- VectorCopy (self->s.origin, start);
-
- start[2] = start[2] + 26;
- VectorCopy (self->enemy->s.origin, end);
- end[2] += self->enemy->viewheight;
- VectorSubtract (end, start, dir);
-
- right[0] = right[0] * 8;
- right[1] = right[1] * 8;
-
- VectorAdd(start, right, start);
- end[2] = end[2] - 32;
-
- VectorCopy (start, from);
- tr = gi.trace (from, NULL, NULL, end, self, MASK_SHOT);
- VectorCopy (tr.endpos, from);
-
- if (self->spawnflags & 1)
- {
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_RAILTRAIL);
- gi.WritePosition (start);
- gi.WritePosition (end);
- gi.multicast (start, MULTICAST_PHS);
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_MEDIC_CABLE_ATTACK);
- gi.WritePosition (start);
- gi.WritePosition (end);
- gi.multicast (start, MULTICAST_PHS);
- gi.sound (self, CHAN_VOICE, sound_punch, 1, ATTN_NORM, 0);
- }
- else
- {
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_SHOTGUN);
- gi.WritePosition (start);
- gi.WritePosition (end);
- gi.multicast (start, MULTICAST_PHS);
- gi.sound (self, CHAN_VOICE, sound_shoot, 1, ATTN_NORM, 0);
- }
-
- if ((tr.ent != self) && (tr.ent->takedamage))
- T_Damage (tr.ent, self, self, dir, tr.endpos, tr.plane.normal, damage, 0, 0, MOD_HYPERBLASTER);
- else if (!((tr.surface) && (tr.surface->flags & SURF_SKY)))
- {
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_SCREEN_SPARKS);
- gi.WritePosition (tr.endpos);
- gi.WriteDir (tr.plane.normal);
- gi.multicast (self->s.origin, MULTICAST_PVS);
- }
- }
-
- mframe_t martian_frames_attack_shoot [] =
- {
- ai_charge, 0, NULL,
- ai_charge, 0, MartianShot,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL
- };
- mmove_t martian_move_attack_shoot = {FRAME_attack1, FRAME_attack8, martian_frames_attack_shoot, martian_run_after_shoot};
-
-
- void martian_sight (edict_t *self, edict_t *other)
- {
- gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
- if(random() < 0.5)
- self->monsterinfo.currentmove = &martian_move_wave;
- else
- self->monsterinfo.currentmove = &martian_move_point;
- }
-
- void martian_melee (edict_t *self)
- {
- self->monsterinfo.currentmove = &martian_move_attack_shoot;
- }
-
- void martian_attack (edict_t *self)
- {
-
- if(random() > 0.5)
- self->monsterinfo.currentmove = &martian_move_point;
- else
- self->monsterinfo.currentmove = &martian_move_attack_shoot;
- }
-
- void martian_duck_down (edict_t *self)
- {
- if (self->monsterinfo.aiflags & AI_DUCKED)
- return;
- self->monsterinfo.aiflags |= AI_DUCKED;
-
-
- self->maxs[2] -= 32;
- self->takedamage = DAMAGE_YES;
- self->monsterinfo.pausetime = level.time + 1;
- gi.linkentity (self);
- }
-
- void martian_duck_hold (edict_t *self)
- {
- if (level.time >= self->monsterinfo.pausetime)
- self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;
- else
- self->monsterinfo.aiflags |= AI_HOLD_FRAME;
- }
-
- void martian_duck_up (edict_t *self)
- {
- self->monsterinfo.aiflags &= ~AI_DUCKED;
- self->maxs[2] += 32;
- self->takedamage = DAMAGE_AIM;
- gi.linkentity (self);
- }
-
- mframe_t martian_frames_duck [] =
- {
- ai_move, 0, martian_duck_down,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, martian_duck_hold,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, martian_duck_up,
- ai_move, 0, NULL
- };
- mmove_t martian_move_duck = {FRAME_duck01, FRAME_duck08, martian_frames_duck, martian_run};
-
- void martian_dodge (edict_t *self, edict_t *attacker, float eta)
- {
- if (random() > 0.25)
- return;
-
- if (!self->enemy)
- self->enemy = attacker;
-
- self->monsterinfo.currentmove = &martian_move_duck;
- }
-
- mframe_t martian_frames_pain1 [] =
- {
-
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t martian_move_pain1 = {FRAME_pain101, FRAME_pain104, martian_frames_pain1, martian_run};
-
-
- mframe_t martian_frames_pain2 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t martian_move_pain2 = {FRAME_pain201, FRAME_pain204, martian_frames_pain2, martian_run};
-
- mframe_t martian_frames_pain3 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t martian_move_pain3 = {FRAME_pain301, FRAME_pain304, martian_frames_pain3, martian_run};
-
- void martian_pain (edict_t *self, edict_t *other, float kick, int damage)
- {
- float spd;
- vec3_t org;
-
- if (level.time < self->pain_debounce_time)
- return;
-
- self->pain_debounce_time = level.time + 3;
-
- if ((self->health < (self->max_health / 2)) && (self->s.skinnum == 0))
- {
- //break the helmet, and put green blood on the martian
- // a bunch of little chunks
- gi.sound (self, CHAN_VOICE, sound_glass, 1, ATTN_NORM, 0);
- spd = 1.5;
- org[0] = self->s.origin[0] + crandom() * 5.0;
- org[1] = self->s.origin[1] + crandom() * 5.0;
- org[2] = self->s.origin[2] + crandom() * 5.0;
- ThrowDebris (self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self->s.origin[0] + crandom() * 5.0;
- org[1] = self->s.origin[1] + crandom() * 5.0;
- org[2] = self->s.origin[2] + crandom() * 5.0;
- ThrowDebris (self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self->s.origin[0] + crandom() * 5.0;
- org[1] = self->s.origin[1] + crandom() * 5.0;
- org[2] = self->s.origin[2] + crandom() * 5.0;
- ThrowDebris (self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self->s.origin[0] + crandom() * 5.0;
- org[1] = self->s.origin[1] + crandom() * 5.0;
- org[2] = self->s.origin[2] + crandom() * 5.0;
- ThrowDebris (self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self->s.origin[0] + crandom() * 5.0;
- org[1] = self->s.origin[1] + crandom() * 5.0;
- org[2] = self->s.origin[2] + crandom() * 5.0;
- ThrowDebris (self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self->s.origin[0] + crandom() * 5.0;
- org[1] = self->s.origin[1] + crandom() * 5.0;
- org[2] = self->s.origin[2] + crandom() * 5.0;
- ThrowDebris (self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self->s.origin[0] + crandom() * 5.0;
- org[1] = self->s.origin[1] + crandom() * 5.0;
- org[2] = self->s.origin[2] + crandom() * 5.0;
- ThrowDebris (self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self->s.origin[0] + crandom() * 5.0;
- org[1] = self->s.origin[1] + crandom() * 5.0;
- org[2] = self->s.origin[2] + crandom() * 5.0;
- ThrowDebris (self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self->s.origin[0] + crandom() * 5.0;
- org[1] = self->s.origin[1] + crandom() * 5.0;
- org[2] = self->s.origin[2] + crandom() * 5.0;
- ThrowDebris (self, "models/objects/debris2/tris.md2", spd, org);
- self->s.modelindex2 = 0;
- self->s.skinnum = 1;
-
- if(random() < 0.3)
- self->monsterinfo.currentmove = &martian_move_pain1;
- else if(random() < 0.5)
- self->monsterinfo.currentmove = &martian_move_pain2;
- else
- self->monsterinfo.currentmove = &martian_move_pain3;
- }
- else
- {
- gi.sound (self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);
-
- if(random() < 0.3)
- self->monsterinfo.currentmove = &martian_move_pain1;
- else if(random() < 0.5)
- self->monsterinfo.currentmove = &martian_move_pain2;
- else
- self->monsterinfo.currentmove = &martian_move_pain3;
- }
- }
-
-
- void martian_dead (edict_t *self)
- {
- VectorSet (self->mins, -16, -16, 0);
- VectorSet (self->maxs, 16, 16, 16);
- self->movetype = MOVETYPE_TOSS;
- self->svflags |= SVF_DEADMONSTER;
- self->nextthink = 0;
- gi.linkentity (self);
- }
-
-
- mframe_t martian_frames_death1 [] =
- {
-
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
-
- };
- mmove_t martian_move_death1 = {FRAME_death101, FRAME_death106, martian_frames_death1, martian_dead};
-
-
- mframe_t martian_frames_death2 [] =
- {
-
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t martian_move_death2 = {FRAME_death201, FRAME_death206, martian_frames_death2, martian_dead};
-
- mframe_t martian_frames_death3 [] =
- {
-
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t martian_move_death3 = {FRAME_death301, FRAME_death307, martian_frames_death3, martian_dead};
-
- void martian_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
- {
- int n;
-
- if (self->health <= self->gib_health)
- {
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
- self->s.modelindex3 = 0;
- for (n = 0; n < 8; n++)
- ThrowGib (self, "models/objects/gibs/mart_gut/tris.md2", damage, GIB_ORGANIC, EF_GREENGIB);
-
- ThrowHead (self, "models/objects/gibs/mart_gut/tris.md2", damage, GIB_ORGANIC, EF_GREENGIB);
- self->deadflag = DEAD_DEAD;
- return;
- }
-
- if (self->deadflag == DEAD_DEAD)
- return;
-
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
- self->deadflag = DEAD_DEAD;
- self->takedamage = DAMAGE_YES;
- self->s.modelindex2 = 0; //get rid of helmet.
- if(random() < 0.3)
- self->monsterinfo.currentmove = &martian_move_death1;
- else if(random() < 0.5)
- self->monsterinfo.currentmove = &martian_move_death2;
- else
- self->monsterinfo.currentmove = &martian_move_death3;
- }
-
-
- /*QUAKED monster_martian (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
- */
- void SP_monster_martian (edict_t *self)
- {
- if (deathmatch->value)
- {
- G_FreeEdict (self);
- return;
- }
-
- // pre-caches
- sound_pain = gi.soundindex ("martian/ack2.wav");
- sound_die = gi.soundindex ("martian/death.wav");
- sound_idle = gi.soundindex ("martian/ack1.wav");
- sound_punch = gi.soundindex ("martian/laser.wav");
- sound_search = gi.soundindex ("martian/ack1.wav");
- sound_sight = gi.soundindex ("martian/ack1.wav");
- sound_shoot = gi.soundindex ("martian/blaster.wav");
- sound_glass = gi.soundindex ("martian/glasbk.wav");
-
- if(self->spawnflags & 1)
- self->s.modelindex = gi.modelindex("models/monsters/hi_res/martian_assassin/tris.md2");
- else
- self->s.modelindex = gi.modelindex("models/monsters/hi_res/martian/tris.md2");
-
- self->s.modelindex2 = gi.modelindex("models/monsters/hi_res/martian_helmet/tris.md2");
-
- self->s.modelindex3 = gi.modelindex("models/monsters/martian_weapon/tris.md2");
-
- VectorSet (self->mins, -16, -16, 0);
- VectorSet (self->maxs, 16, 16, 64);
- self->movetype = MOVETYPE_STEP;
- self->solid = SOLID_BBOX;
-
- self->classname = "monster_martian";
-
- self->max_health = 150;
- self->health = self->max_health;
- self->gib_health = -40;
- self->mass = 150;
-
- self->pain = martian_pain;
- self->die = martian_die;
- self->monsterinfo.stand = martian_stand;
- self->monsterinfo.walk = martian_run;
- self->monsterinfo.run = martian_run;
- self->monsterinfo.dodge = martian_dodge;
- self->monsterinfo.attack = martian_attack;
- self->monsterinfo.melee = martian_melee;
- self->monsterinfo.sight = martian_sight;
- self->monsterinfo.search = martian_search;
-
- self->monsterinfo.currentmove = &martian_move_stand;
- self->monsterinfo.scale = MODEL_SCALE;
-
- gi.linkentity (self);
-
- walkmonster_start (self);
- }
-